/*
 * trace_CmdListMeta.c
 *
 *  Created on: 2012/07/11
 *      Author: guanxiaoying
 */

#include "../table.h"
#include "../trace_cmd_table.h"
typedef struct _CMDLISTMETA
{
	UCHAR       times;
	AST			astInLoop;		/* 4 	*/
	AST			astPath;	/* 7 */
	AST 		astPathIn;
	AST 		astPathOut;
	AST 		astPathParam;
	AST         astLog;
} CMDLISTMETA, *PCMDLISTMETA;

#define TableSize  (sizeof(CMDLISTMETA ))
#define TableType  PCMDLISTMETA
#define stTable stCmdListMetaManager.memoryBlocks
#define maxTable stCmdListMetaManager.maxRecordNum
#define  maxNumPerBlk  (stCmdListMetaManager.astMaxNum_Block)


static TABLEMANAGER stCmdListMetaManager = {
//		U4                  usIdx;
		0,
//		PSZ				    con_pszName;    constant
		__FILE__,
//		U2					con_usSize;		constant
		TableSize,
//		U2					block_num;	　　　　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_Block;     １回設定のみ
		0,
//		S4					astTabNum_LastPage; 　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_LastPage;     Reset clear  際　要
		0,
//		U4					ulMaxByte;	　　　　　　　　　　クリアしない
		0,
//		U4					con_minPageSize;　　　　　　　　　　constant
		0
};
static VOID resetListener( U4  procid, U2 index )
{
	if( procid == stCmdListMetaManager.u4Idx )
	{
		if( index > 0 && index < MAX_VOLUMN_OF_TABLE )
		{
			stTable[ index-1] = NULL;
		}
	}
}
static TableType core_getTable( AST index )
{
	TableType temp = (TableType)Check_Com( &stCmdListMetaManager, resetListener,  index );
	if( temp != NULL ){ return &temp[index%maxNumPerBlk]; } return NULL;
}
static BOOL ClearTable( VOID )
{
	return Clear_Com( &stCmdListMetaManager );
}
static BOOL AllocTable( AST astReqArg )
{
	return AllocTable_Com( &stCmdListMetaManager, astReqArg, resetListener );
}
static AST getMaxLineNum( VOID ){
	return maxTable;
}
static U2 getTimes( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->times;
}
static U2 setTimes( AST astIndex, U2 value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->times=value;
}
static AST getInLoop( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astInLoop;
}
static AST setInLoop( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astInLoop=value;
}
static AST getPath( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPath;
}
static AST setPath( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPath=value;
}
static AST getPathIn( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathIn;
}
static AST setPathIn( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathIn=value;
}
static AST getPathOut( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathOut;
}
static AST setPathOut( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathOut=value;
}
//static AST getPathParam( AST astIndex ){
//	TableType pTbl = core_getTable( astIndex );
//	if( pTbl == NULL )
//	{
//		return 0;
//	}
//	return pTbl->astPathParam;
//}
//static AST setPathParam( AST astIndex, AST value ){
//	TableType pTbl = core_getTable( astIndex );
//	if( pTbl == NULL )
//	{
//		return 0;
//	}
//	return pTbl->astPathParam=value;
//}
static AST getLogging( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astLog;
}
static AST setLogging( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astLog=value;
}
const CMDLISTMETAACCESS stCmdListMetaAccess = {
		ClearTable,
		AllocTable,
		getMaxLineNum,
		{
				getTimes,
				setTimes
		},
		{
				getInLoop,
				setInLoop
		},
		{
				getPath,
				setPath
		},
		{
				getPathIn,
				setPathIn
		},
		{
				getPathOut,
				setPathOut
		},
//		{
//				getPathParam,
//				setPathParam
//		},
		{
				getLogging,
				setLogging
		}

};




